import os
import django
from celery import Celery, platforms
from django.conf import settings
from celery.schedules import crontab

# 设置环境变量
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "application.settings")
django.setup()

# 实例化
app = Celery(f"application")


app.config_from_object("django.conf:settings",namespace="CELERY")
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.autodiscover_tasks()


app.conf.beat_schedule={
    'my-task':{
        'task':'application.apps.prescrption.task.my_task',
        'schedule':crontab(hour=16,minute=22)
    }
}
